<?php
/**
*	接口文件
*	createname：雨中磐石
*	homeurl：http://www.rockoa.com/
*	Copyright (c) 2016 rainrock (www.rockoa.com)
*	Date:2016-01-01
*	explain：返回200为正常
*/


class apiAction extends ActionNot
{
	public $agentrs;
	public $usersrs;
	public $agentid	= 0;
	public $platid	= 0; //平台用户id
	public $agentkey= '';
	
	public function initAction()
	{
		$this->display	= false;
		$agentkey		= $this->get('agentkey');
		if(isempt($agentkey)){
			$gokey = $this->get('gokey');
			if(!isempt($gokey))$agentkey = c('cache')->get($gokey);
		}
		if(isempt($agentkey)){
			$agentkey	= $this->get('_w_agentkey');
			if(!isempt($agentkey))$agentkey = $this->jm->uncrypt($agentkey);
		}
		
		if(isempt($agentkey))showreturn('','agentkey is empty', 199);
		
		$this->agentrs	= m('agent')->getone("`agentkey`='$agentkey'");
		if(!$this->agentrs)showreturn('','在线编辑agentkey无效', 198);
		$this->agentkey= $this->agentrs['agentkey'];
		$this->agentid = $this->agentrs['id'];
		$this->platid  = $this->agentrs['platid'];
		$this->usersrs = m('users')->getone($this->platid);
		if(arrvalue($this->usersrs,'status','0')=='0')showreturn('','用户停用可能不是vip用户', 197);
	}
	
	public function getvals($nae, $dev='')
	{
		$sv = $this->rock->jm->base64decode($this->post($nae));
		if($this->isempt($sv))$sv=$dev;
		return $sv;
	}
	
	public function getpostdata()
	{
		$postdata = '';
		if(isset($GLOBALS['HTTP_RAW_POST_DATA']))$postdata = $GLOBALS['HTTP_RAW_POST_DATA'];
		if($postdata=='')$postdata = trim(file_get_contents('php://input'));
		return $postdata;
	}
}